package com.hzw.code

import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import com.hzw.code.annotation.BindViewModel
import com.hzw.code.bean.CommonTitleLayout
import com.hzw.code.vm.PageActivity
import com.hzw.code.vm.TitleLayout
import kotlinx.android.synthetic.main.activity_normal.*

class NormalActivity : PageActivity() {

    @BindViewModel(NormalViewModel::class)
    lateinit var viewModel: NormalViewModel

    override fun getLayoutResId(): Int = R.layout.activity_normal

    override fun initTitleLayout(): TitleLayout? {
        return CommonTitleLayout(this)
    }

    override fun init(savedInstanceState: Bundle?) {
        loadData.setOnClickListener {
            viewModel.loadConsultationList()
        }

        loadFragment.setOnClickListener {
            fragmentContainer.visibility = View.VISIBLE
            val beginTransaction = supportFragmentManager.beginTransaction()
            beginTransaction.replace(R.id.fragmentContainer, NormalFragment())
            beginTransaction.commitNow()
        }

//        viewModel.workspaceLiveData.observe(this, Observer {
//            logText.text = it.toString()
//        })

        viewModel.patientDetailLiveData.observe(this, Observer {
            logText.text = it.toString()
        })
    }


}
